import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sports_new/controller/service/config_service.dart';
import 'package:sports_new/resources/colours.dart';
import 'package:sports_new/resources/styles.dart';
import 'package:sports_new/utils/utils.dart';
import 'package:sports_new/utils/widget_utils.dart';
import 'package:sports_new/widgets/base/qkd_widget.dart';

import '../../../widgets/base/qkd_text.dart';

class OddsCompanyPage extends StatefulWidget {
  const OddsCompanyPage({super.key});

  @override
  State<OddsCompanyPage> createState() => _OddsCompanyPageState();
}

class _OddsCompanyPageState extends State<OddsCompanyPage> {
  ConfigService configService = Get.find<ConfigService>();
  //0足球  1篮球
  int type = Get.arguments;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: Styles.appBar(title: QkdText(type == 0 ? '足球指数公司' : '篮球指数公司')),
      backgroundColor: Colours.scaffoldBg,
      body: ListView(children: [
        SizedBox(height: 10),
        Styles.card(
          margin: EdgeInsets.symmetric(horizontal: 8),
          child: Column(
            children: configService.oddsCompany.map<Widget>((e) {
              if(type == 0) {
                return QkdWidget.selectCell(e.name ?? '',
                  configService.zqConfig.zqList8 == e.id,
                  onTap: () {
                    configService.zqConfig.zqList8 = e.id!;
                    update();
                    configService.update(ConfigType.zqList8, configService.zqConfig.zqList8);
                  }
                );
              }else{
                return QkdWidget.selectCell(
                  e.name ?? '',
                  configService.lqConfig.lqList8 == e.id,
                  onTap: () {
                    configService.lqConfig.lqList8 =
                    e.id!;
                    update();
                    configService.update(
                      ConfigType.lqList8, configService.lqConfig.lqList8
                    );
                  }
                );
              }
            }).toList().insertEvery(QkdWidget.seperateLine())
          )
        )
      ]),
    );
  }
}
